{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Received data:\n",
      " {{006PSPD!}}\n",
      "[CMDRESP]\n"
     ]
    }
   ],
   "source": [
    "# Create a TCP client to connect to the ESP32 server\n",
    "import socket\n",
    "\n",
    "IP=\"192.168.1.106\"\n",
    "PORT=10000\n",
    "BUFFER_SIZE=1024\n",
    "\n",
    "# create a socket object\n",
    "s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
    "\n",
    "# connect to server\n",
    "s.connect((IP, PORT))\n",
    "\n",
    "# send data to server\n",
    "message = \"{{006PSPD!}}\"\n",
    "s.send(message.encode())\n",
    "\n",
    "# receive data from server\n",
    "data = s.recv(BUFFER_SIZE)\n",
    "\n",
    "print(\"Received data:\\n\", data.decode())\n",
    "\n",
    "# close the connection\n",
    "s.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
